package Thread;

class Teacher{
    static Object object = new Object();
    public static void EnglishClass(){
        synchronized (object){
            if(ThreadDemo14.size >= 0){
                System.out.println("ABCDEFG...."+ThreadDemo14.size);
                ThreadDemo14.size--;
            }
        }
    }
}
public class ThreadDemo14 {
  public static int size = 50;
    public static void main(String[] args) {
        Thread A = new Thread(()->{
            while (size >= 0)
                    Teacher.EnglishClass();
        }) ;
        Thread B = new Thread(()->{
            while (size >= 0)
                    Teacher.EnglishClass();
        }) ;

        A.start();
        B.start();
    }
}
